<?php

# PMB Online
# Aplikasi PMB Online untuk Pendaftaran Calon Mahasiswa di PT/PTS Indonesia
# 
# version 1.0
# class admin
# file controllers/admin.php
# created Jan 23, 2013 4:23:24 AM
# 
# (c)2012, arif.laksito@gmail.com

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Admin extends CI_Controller{
    
    var $data = array();

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        
        $this->load->model('authlogin');
        if($this->authlogin->valid_cookies()){
            redirect('apps');            
        }else{
            $this->data['post'] = array('usr'=>'');
            $this->load->view('admin_login', $this->data);
        }
                
    }
    
    public function in(){
        $post = $this->input->post();
        
        if($post){
            $this->load->model('authlogin');            
            
            if ($this->authlogin->login($post['usr'], $post['pwd'])) {
                $this->authlogin->set_cookies();
                
                redirect('apps');
                
            } else {
                $this->data['post'] = $post;
                $this->data['msg'] = $this->authlogin->umsg;
                $this->load->view('admin_login', $this->data);
            }
        
        }
                        
    }
    
    public function out(){
        $this->load->model('authlogin');
        $this->authlogin->del_cookies();
        
        redirect('admin');
    }
}